const constans = require('../../constans/constans.js');
const request = require('../../request.js');
const Toast = require('../../utils/Toast.js');
const LogUtils = require('../../utils/LogUtils.js');
const util = require('../../utils/util.js')
const app = getApp();

Page({
  data: {
    logs: [],
    height1: '',
    name:'meiyou',
    useimage:'../../img/12.jpg',
    yue:'0.00',
    bindPhone:'',
  },
  onShow: function () {
    let that=this;
    if (!this.data.isClose) {
      console.log(wx.getStorageSync('num_na'));
      wx.setStorageSync('num_na', parseFloat(wx.getStorageSync('num_na')).toFixed(2))
      if (wx.getStorageSync('num_na')==undefined){
        return;
      }
     
      this.setData({

        yue: wx.getStorageSync('num_na')
      });
    }
    request.get(
      constans.getProfile,
      {},
      function (data) {
        console.log(data)
        that.setData({
          name: data.data.data.nickname,
          useimage: data.data.data.avatar,
          yue: (data.data.data.remain / 100).toFixed(2),
          bindPhone: data.data.data.phone,
        });
      })
  },
  onLoad: function (e) {
    
    
    app.requestHeader = { 'Authorization': wx.getStorageSync('Authorization') }
    // if (wx.getStorageSync('num_na') == 1) {
    //   wx.setStorageSync('num_na',2)
    //   wx.navigateTo({
    //     url: '../wode/wode'
    //   })
    // }
    let that = this;
    // 获取系统信息
    wx.getSystemInfo({
      success: function (res) {
        // 获取可使用窗口宽度
        let clientHeight = res.windowHeight;
        // 获取可使用窗口高度
        let clientWidth = res.windowWidth;
        // 算出比例
        let ratio = 750 / clientWidth;
        // 算出高度(单位rpx)
        let height = clientHeight * ratio;
        // 设置高度
        that.setData({
          height1: height
        });
      }
    });
  
  },
  detail: function () {
    wx.navigateTo({
      url: '../detail/detail'
    })
  },
  problem: function () {
    wx.navigateTo({
      url: '../problem/problem'
    })
  },
 
  deposit: function () {
    wx.navigateTo({
      url: '../deposit/deposit'
    })
  },

  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
    }
    request.get(
      constans.addShareRecord,
      { activityId: wx.getStorageSync('activityId'), packageId: wx.getStorageSync('packageId')},
      function (data) {

        if (data.data.code == 0) {
          console.log('分享成功')
          console.log(data)
        } else {
          wx.showModal({
            title: '提示',
            showCancel: false,
            content: data.data.message,
          })
        }
      })
    return {
      title: wx.getStorageSync('title') + "邀您翻牌子",
      imageUrl: '../../img/Gran.jpg',
      path: "pages/packet/packet?c=share&a=" + wx.getStorageSync('activityId') + "&invitation=" + wx.getStorageSync('invitation') + "&timestamp=" + Date.parse(new Date()) + "&p=" + wx.getStorageSync('packageId')
    

       
       
      
    }
  },
  bindPhoneTo:function(){
    wx.navigateTo({
      url: '../bindPhone/bindPhone'
    })
  }
  
  
})